package com.fumihiko.modules.ca.dao;

import com.fumihiko.modules.ca.vo.UserAppinfoVo;
import com.fumihiko.modules.ca.vo.UserTokenVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserTokenMapper {

    @Insert("insert into tb_user_token(app_id, app_secret, access_token, expiration_time) values(#{appId}, #{appSecret}, #{accessToken}, #{expirationTime})")
    public void insertUserTokenObj(UserTokenVo userTokenVo);

    @Select("select * from tb_user_token where app_id = #{appId} and app_secret = #{appSecret}")
    public List<UserTokenVo> getUserTokenVoObj(@Param("appId") String appId, @Param("appSecret") String appSecret);

    @Update("update tb_user_token set access_token = #{accessToken}, expiration_time = #{expirationTime} where app_id = #{appId} and app_secret = #{appSecret}")
    public void updateUserTokenVoObj(UserTokenVo userTokenVo);

    @Delete("delete from tb_user_token where app_id = #{appId} and app_secret = #{appSecret}  and access_token = #{accessToken}")
    public void deleteUserTokenVoObj(@Param("appId") String appId, @Param("appSecret") String appSecret, @Param("accessToken") String accessToken);

    @Select("select * from tb_user_token where access_token = #{accessToken}")
    public UserTokenVo getUserTokenVoObjByAccessToken(@Param("accessToken") String accessToken);

    @Update("update tb_user_token set area_code = #{areaCode} where access_token = #{accessToken} ")
    public void updateUserTokenVoAreaCode(@Param("areaCode") String areaCode, @Param("accessToken") String accessToken);

    @Select("select * from tb_user_token")
    public List<UserTokenVo> getUserTokenList();
}
